package com.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Test03 implements Callable {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        // 通过实现callable接口来调用多线程
        Test03 test03 = new Test03();
        FutureTask<String> futureTask = new FutureTask<>(test03);
        Thread thread= new Thread(futureTask);
        thread.start();
        String s = futureTask.get();
        System.out.println(s);
    }

    @Override
    public String call() throws Exception {
        System.out.println("通过实现callable接口来调用多线程");
        return "success";
    }
}
